#ifndef _MSG_LIST_H
#define _MSG_LIST_H

#include<iostream>
#include<list>
#include<pthread.h>



typedef struct _msg_recv
{
   int fd;
   unsigned int peerIp;
   unsigned short peerPort;   
   unsigned int msgLen;
   char buff[100]; 
}msg_recv;

msg_recv * msgRecvInit(unsigned int len, char * buffIn,unsigned int peerIpIn, unsigned short peerPort,int fd);

void msgRecvFree(msg_recv * ptrMsg);

class CRecvPool
{
private:
    pthread_mutex_t mutexList;
    std::list<msg_recv*> msgList;
    std::list<msg_recv*>::iterator iterList;
	
	pthread_mutex_t mutexList_Send;
	std::list<msg_recv*> msgListSend;
public:
    CRecvPool();
    virtual ~CRecvPool();
public:
    int addOneMsg(unsigned int len, char * buff, unsigned int peerIp,unsigned short peerPort,int fd,int isRecv);
    msg_recv * getOneMsg(int isRecv);
};

extern CRecvPool * g_ptrRecvPool;

#define UPDATE_IP_CODE 0x34
#define ACK_CODE       0x35

#endif
